package org.example;

import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.util.XmlUtil;
import java.io.FileNotFoundException;
import java.util.List;
import javax.xml.xpath.XPathConstants;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

/**
 * @author : libo@juzishuke.com
 * @Title :
 * @Description :
 * @date : 2024/1/23 15:05
 * @since :1.0
 */
@Slf4j
public class HutoolTest {

    public static void main(String[] args) throws FileNotFoundException, DocumentException {
//        Document document = XmlUtil.readXML(new FileReader("toc.xml").getInputStream());
//        Object navMap = XmlUtil.getByXPath("//ncx", document, XPathConstants.NODE);
//        System.out.println(navMap);
        SAXReader reader = new SAXReader();
        Document document = reader.read((new FileReader("toc.xml").getInputStream()));
        List<Node> list = document.selectNodes("//ncx//navMap");
        System.out.println(list.size());
    }

}
